<template>
  <div class="login">
    <login-box @login="login"></login-box>
  </div>
</template>

<script>
import LoginBox from './components/LoginBox.vue'
import { userLogin, getUserInfo } from '@/api/api'
export default {
  name: 'Login',
  components: {
    LoginBox
  },
  methods: {
    // 点击登录按钮
    login(formData) {
      userLogin(formData).then((res) => {
        const token = res.data.data.token
        console.log(res.data.data.token)
        this.$store.commit('setToken', token)
        getUserInfo().then((res) => {
          console.log(res)
          console.log(res.data.data)
          this.$store.commit('setUser', res.data.data)
          this.$router.push('/')
        })
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.login {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  // background-image: url(/_nuxt/img/c2de7dc.png);
  background-repeat: no-repeat;
  background-size: cover;
  background-image: url('https://www.yunliyunwai.cn/_nuxt/img/c2de7dc.png');
}
</style>
